
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[UserInfoIsExist]
    @Login VARBINARY(MAX) ,
    @Id UNIQUEIDENTIFIER
AS 
    BEGIN
        IF ( @Id = NULL ) 
            BEGIN
                SELECT  COUNT(*)
                FROM    UserInfo
                WHERE   LOGIN = @Login
                        AND DELETED = 0
            END
        ELSE 
            BEGIN
                SELECT  COUNT(*)
                FROM    UserInfo
                WHERE   LOGIN = @Login
                        AND Id != @Id
                        AND DELETED = 0
            END
                
    END
GO
